/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       saved_combat_context.h

	$Header: /game/saved_combat_context.h $

	$NoKeywords: $

 ************************************************************************/

#if !defined( COMBAT_CONTEXT_H_INCLUDED )
#define COMBAT_CONTEXT_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "adv_map_point.h"
#include "creature_array.h"

class t_adventure_frame;
class t_adventure_map;
enum  t_combat_result;
class t_creature_array;
class t_ownable_garrisonable_adv_object;
class t_town;

enum t_combat_context_type
{
	k_combat_context_type_adv_object,
	k_combat_context_type_army,
	k_combat_context_type_dwelling,	
	k_combat_context_type_script,
	k_combat_context_type_count
};

class t_combat_context : public t_counted_object
{
public:
	virtual ~t_combat_context();

	t_adventure_frame*							get_adventure_frame() const;
	t_adventure_map*							get_adventure_map() const;
	virtual bool const *						get_are_real_armies() const;
	t_creature_array*							get_attacker() const;
	t_creature_array*							get_defender() const;
	t_ownable_garrisonable_adv_object const*	get_garrison() const;
	t_adv_map_point const&						get_location() const;
	t_creature_array*							get_losses();
	t_town*										get_town() const;
	virtual t_combat_context_type				get_type() const = 0;
	virtual void								on_combat_end( t_combat_result result ) = 0;
	virtual bool								read( std::streambuf& stream, 
													  t_adventure_map& adventure_map ) = 0;
	virtual bool								save_allowed() const;
	void										set_cursor_visible( bool arg );
	bool										was_cursor_visible() const;
	virtual bool								write( std::streambuf& stream ) const = 0;
protected:
	t_combat_context();
	t_combat_context( t_creature_array*							attacker, 
					  t_creature_array*							defender,
					  t_adv_map_point const&					location,
					  t_town*									town,
					  t_ownable_garrisonable_adv_object const*	garrison );
	bool	base_read( std::streambuf& stream, t_adventure_map& adventure_map );
	bool	base_read( std::streambuf& stream, t_adventure_map& adventure_map, int version );

	t_creature_array*							m_attacker;
	t_creature_array*							m_defender;
	t_ownable_garrisonable_adv_object const*	m_garrison;
	t_adv_map_point								m_location;
	t_creature_array							m_losses[2];
	t_town*										m_town;
	bool										m_was_cursor_visible;
};


inline t_combat_context::t_combat_context()
{
	m_attacker = 0;
	m_defender = 0;
	m_was_cursor_visible = true;
}

inline t_creature_array* t_combat_context::get_attacker() const
{
	return m_attacker;
}

inline t_creature_array* t_combat_context::get_defender() const
{
	return m_defender;
}

inline t_ownable_garrisonable_adv_object const*	t_combat_context::get_garrison() const
{
	return m_garrison;
}

inline t_adv_map_point const& t_combat_context::get_location() const
{
	return m_location;
}

inline t_creature_array* t_combat_context::get_losses()
{
	return m_losses;
}

inline t_town* t_combat_context::get_town() const
{
	return m_town;
}

inline void t_combat_context::set_cursor_visible( bool arg )
{
	m_was_cursor_visible = arg;
}

inline bool t_combat_context::was_cursor_visible() const
{
	return m_was_cursor_visible;
}

#endif // saved_combat_context